#include <stdio.h>

int data[20000];

int binary_search_recursive(int d[], int s, int e, int q)
{
    if (s >= e) return -1;
    int mid = (s + e) / 2;
    if (d[mid] == q)
        return mid;
    else if (d[mid] > q)
        return binary_search(d, s, mid, q);
    else
        return binary_search(d, mid + 1, e, q);
}

int binary_search(int d[], int s, int e, int q)
{
    int left = s - 1, right = e, mid;
    while (left + 1 < right)
    {
        mid = (left + right) / 2;
        if (d[mid] == q)
            return mid;
        else if (d[mid] < q)
            left = mid;
        else 
            right = mid;
    }
    return -1;
}

int main()
{
    int i, m, n, s, e, q;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", data + i);
    scanf("%d", &m);
    for (i = 0; i < m; i++) {
        scanf("%d%d%d", &s, &e, &q);
        printf("%d\n", binary_search(data, s, e, q));
    }
    return 0;
}
